package engine.combat;

import java.util.Random;
import creatures.Creature;
import creatures.Limb;

/**
 * This class handles combat calculations.
 * 
 * @see engine.combat.Attack
 * @see engine.combat.Stats
 * @author Kyle_Solo
 */
public class Combat {
	/**
	 * Attack is called by classes who implement the Combatant interface.
	 * <p>
	 * Sample implementation:<br>
	 * <code>
	 * defenderBase.hp -= attackerModified.strength -
	 * attackerModified.fearForGoats + attackerModified.hatredOfGoats -
	 * defenderModified.damageReduction(attack.damageType);</code><br>
	 * Obviously this will be far more complicated, probably look up from a table of armor
	 * types/attack types and then apply formula(s) or something.
	 * 
	 * @param attacker
	 *            the combatant that is attacking
	 * @param defender
	 *            the combatant that is under attack
	 * @param attack
	 *            the attack
	 */
	public static void attack(Combatant attacker, Combatant defender, Attack attack) {
		// get the involved creature's base and modified stats
		Stats attackerBase = attacker.getStats();
		Stats attackerModified = attacker.getModifiedStats(); // this can't be altered
		Stats defenderBase = defender.getStats();
		Stats defenderModified = defender.getModifiedStats(); // this can't be altered
		
		
		
	}
	
	/**
	 * get a random limb from the target creature. A value of 
	 * null means that the body was hit
	 * @param victim
	 * @return targeted limb
	 */
	public Limb limbChance(Creature victim){
		Limb smacked = null;
		Random random = new Random(victim.limbs.size()+1);
		int limbNum = random.nextInt();
		
		if (limbNum < victim.limbs.size()){
			smacked = victim.limbs.get(limbNum);
		}
		
		return smacked;
	}
	
	/**
	 * get the limb that will be hit by the attack based
	 * on the attacker's weapon skill
	 * @param victim 
	 * @param target
	 * @param weapon
	 * @return targeted limb
	 */
	public Limb limbChance(Creature victim, Limb target, Skill weapon){
		Limb smacked = null;
		
		return smacked;
	}
}